package com.hmsm.sys.action;

import com.hmsm.sys.po.DeptInfo;
import com.hmsm.sys.po.UserInfo;
import com.hmsm.sys.service.DeptInfoService;
import com.hmsm.sys.service.UserInfoService;
import com.lzyyj.gmis.base.dao.IBaseDao;

@SuppressWarnings("serial")
public class UserAction extends com.lzyyj.gmis.base.webui.action.BaseAction<UserInfo, Integer>{
	
	private DeptInfoService deptInfoService;

	public DeptInfoService getDeptInfoService() {
		return deptInfoService;
	}

	public void setDeptInfoService(DeptInfoService deptInfoService) {
		this.deptInfoService = deptInfoService;
	}

	private UserInfoService userInfoService;
	
	public UserInfoService getUserInfoService() {
		return userInfoService;
	}

	public void setUserInfoService(UserInfoService userInfoService) {
		this.userInfoService = userInfoService;
	}

	public UserAction(){
		super();
		page.setPageSize(5);
		page.setFindByExample(new UserInfo());
		page.getCondition().put(IBaseDao.PROPERTY_LIST, "userName,name,userDept");
		page.getCondition().put(IBaseDao.EXAMPLE_PROPERTIES, "depart");
	}
	
	@Override
	public String manage() {
		String result = super.manage();
		if (SUCCESS.equals(result)){
			DeptInfo parent = null;
			try {
//				parent = getBaseService().get(page.getFindByExample().getDepart());
//				page.getFindByExample().setDepart(parent);
//				page = getDeptInfoService().userManage(page);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				this.addActionError("发生错误："+e);
				result = ERROR;
			}
		}
		
		return result;
	}

	@Override
	public String add() {
		setItemPropertyList("parId");
		String result = super.add();
		if (SUCCESS.equals(result)){
			try {
//				loadParamList();
				setDefinedResult("edit");
				result = "definedResult";
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				this.addActionError("发生错误："+e);
				result = ERROR;
			}
		}
		return result;
	}

	@Override
	public String edit() {
		setItemPropertyList("name,parent,deptType,org.name,deptNo,relevanceConfig");
		String result = super.edit();
		try {
//			loadParamList();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			this.addActionError("发生错误："+e);
			result = ERROR;
		}
		
		return result;
	}
	
	@Override
	public String save() {
		setItemPropertyList("parent,name,deptNo,deptType,relevanceConfig");
		String result = super.save();
		result = checkAjax(result);
		return result;
	}

}
